<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->


<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="DC.Type" content="topic">
<meta name="DC.Title" content="Obtaining the kubeconfig Configuration File">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="kubernetes_gud_00065">
<meta name="DC.Language" content="en-us">
<link rel="stylesheet" type="text/css" href="public_sys-resources/commonltr.css">
<title>Obtaining the kubeconfig Configuration File</title>
</head>
<body style="clear:both; padding-left:10px; padding-top:5px; padding-right:5px; padding-bottom:5px"><a name="kubernetes_gud_00065"></a><a name="kubernetes_gud_00065"></a>

<h1 class="topictitle1">Obtaining the kubeconfig Configuration File</h1>
<div><div class="section"><h4 class="sectiontitle">Prerequisites</h4><p>You have obtained the K8s client certificate file <strong>client.crt</strong> and certificate plaintext private key file <strong>client_decrypt.key</strong>. For details about how to obtain the files, see "Generating a K8s Client Certificate" in the <em>(For Engineer) DigitalEP V600R005C00 Product Documentation</em>.</p>
</div>
<div class="section"><h4 class="sectiontitle">Procedure</h4><ol><li><span>Log in to the production host and go to the <strong>/opt/paas/srv/kubernetes</strong> directory.</span></li><li><span>Run the following command to replicate the <strong>kubeconfig_crypto</strong> file to generate the <strong>kubeconfig</strong> file:</span><p><pre class="screen">cp -p kubeconfig_crypto kubeconfig</pre>
</p></li><li><span>Run the following command to generate the Base64 stream of the certificate private key:</span><p><pre class="screen">tls_base_encode_key=$(cat client_decrypt.key | base64 | tr -d "\n")</pre>
</p></li><li><span>Run the following command to generate the Base64 stream of the client certificate:</span><p><pre class="screen">tls_server_key_base64=$(cat client.crt | base64 | tr -d "\n")</pre>
</p></li><li><span>Run the following commands to replace the content of file <strong>kubeconfig</strong>:</span><p><pre class="screen">sed -i "s|client-key-data:.*|client-key-data: ${tls_base_encode_key}|g" kubeconfig</pre>
<pre class="screen">sed -i "s|client-certificate-data:.*|client-certificate-data: ${tls_server_key_base64}|g" kubeconfig</pre>
</p></li></ol>
</div>
<p></p>
</div>

<div class="hrcopyright"><hr size="2"></div><div class="hwcopyright">Copyright &copy; Huawei Technologies Co., Ltd.</div></body>
</html>